import java.util.Scanner;

public class demo03 {
    //最大距离
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] arr=new int[n];
        for (int i = 0; i < n; i++) {
            arr[i]=sc.nextInt();
        }
        int max=0;
        for (int i = 0; i < n; i++) {
            for (int j = i+1; j < n; j++) {
                int num=Math.abs(i-j)+Math.abs(arr[i]-arr[j]);
                if(num>max){
                    max=num;
                }
            }
        }
        System.out.println(max);
    }
}
